package com.smartmedical.patient.share.controller;

import com.smartmedical.common.core.domain.HealthR;
import com.smartmedical.patient.share.domain.Information;
import com.smartmedical.patient.share.domain.InformationPlate;
import com.smartmedical.patient.share.domain.PopularSearch;
import com.smartmedical.patient.share.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

import static com.github.pagehelper.page.PageMethod.startPage;

@RestController
@RequestMapping("/share/information/v1")
public class InformationController {
    @Autowired
    private InformationService informationService;
    /**
     *  健康资讯分类类目查询
     */
    @GetMapping("findInformationPlateList")
    public HealthR<List<InformationPlate>> findInformationPlateList(){
        ArrayList<InformationPlate> result = new ArrayList<>();
        result.add(informationService.findInformationPlateList());
        return HealthR.ok(result);
    }
    /**
     * 根据资讯板块查询资讯列表数据
     * @RequestParam入参
     *plateId 资讯板块id
     * page 页数
     * count 每页显示条数
     */
    @GetMapping("findInformationList")
    public HealthR<List<Information>> findInformationList(@RequestParam(value = "plateId") int plateId, @RequestParam(value = "page",defaultValue = "1") int page, @RequestParam(value = "count",defaultValue = "10") int count){
        startPage(page,count);
        return HealthR.ok(informationService.findInformationList(plateId));
    }
    /**
     *  查询资讯详情
     *  @RequestParam入参
     * infoId 资讯id
     * @RequestHeader入参
     * userId 用户id
     * sessionId 用户sessionId
     */
    @GetMapping("findInformation")
    public HealthR<Information> findInformation(@RequestParam(value = "infoId") int infoId, @RequestHeader("userId") String userId ,@RequestHeader("sessionId") String sessionId){
        return HealthR.ok(informationService.findInformation(infoId));
    }




}
